const express = require('express');
const router = express.Router();
const { login, register, getAllUsers, getUserById,deleteUser, updateUser, uploadXlsxUsers, updatePassword,updateIntroduction,addCounselorFreeTime,updateCounselorFreeTime } = require('../controllers/user');
const { bookConsultationRoom, getAppointmentInfo,getConsultationRoomList,updateConsultationRoom, cancelConsultationRoom,getUserNotifications,markNotificationAsRead,getConsultationRoomInfo,getCounselorFreeTime } = require('../controllers/room')
const { upload, uploadFileLocal } = require('../controllers/document')
const { addPsychologyKnowledge, getPsychologyKnowledgeList,updatePsychologyKnowledge,deletePsychologyKnowledge, likePsychologyKnowledge,uploadXlsxPsychologyKnowledge,getRandomPsychologyKnowledge,searchPsychologyKnowledge,getPsychologyKnowledgeById } = require('../controllers/knowledge')
const { createQuestionnaire,
    getQuestionnaireList,
    updateQuestionnaire,
    deleteQuestionnaire,
    addQuestion,
    getQuestionList,
    updateQuestion,
    deleteQuestion,
    addQuestionToQuestionnaire,
    removeQuestionFromQuestionnaire,
    getQuestionnaireQuestions,
    createPsychologyReport,
    getUserPsychologyReports,
    updatePsychologyReport,
    deletePsychologyReport,
    uploadXlsxQuestions,
    submitQuestionnaire,
    gradeQuestionnaire,
    getPsychologyReportDetails,
    generatePsychologyReport,
    ImportQuestionScoreRanges,ImportQuestions } = require('../controllers/questions')
const { getPendingReviewUsers, reviewUser, batchReviewUsers,getCounselorApplications,getAssistantApplications,applyForRole } = require('../controllers/reviewuser')
const { uploadFile,uploadImage } = require('../controllers/oss');


router.post('/login', login)
router.post('/register', register)

// 用户管理路由
router.post('/getAllUsers',getAllUsers);
router.post('/getUserById', getUserById);
router.post('/deleteUser',deleteUser);
router.post('/updateUser', updateUser);
router.post('/updateIntroduction', updateIntroduction);
router.post('/updatePassword',updatePassword);
router.post('/updateCounselorFreeTime',updateCounselorFreeTime);
router.post('/addCounselorFreeTime',addCounselorFreeTime);//获取咨询师空闲时间信息

// 批量导入用户路由
router.post('/uploadXlsxUsers', upload.single('file'), uploadXlsxUsers);

// 管理员路由
router.post('/getPendingReviewUsers', getPendingReviewUsers);
router.post('/reviewUser', reviewUser);
router.post('/batchReviewUsers', batchReviewUsers);
router.post('/getCounselorApplications', getCounselorApplications);
router.post('/getAssistantApplications', getAssistantApplications);
router.post('/applyForRole', applyForRole);// 用户路由


//router.post('/checkModifyPermission',checkModifyPermission);

// 预约咨询室 (需咨询师/管理员权限)
router.post('/getAppointmentInfo', getAppointmentInfo);
router.post('/getConsultationRoomInfo', getConsultationRoomInfo);// 获取咨询室信息
router.post('/getCounselorFreeTime',getCounselorFreeTime);// 获取咨询师空闲信息
router.post('/bookConsultationRoom',bookConsultationRoom);
//router.post('/getConsultationRoomList', getConsultationRoomList);
router.post('/updateConsultationRoom',updateConsultationRoom);// 更新预约 (需权限)
router.post('/cancelConsultationRoom', cancelConsultationRoom);// 取消预约 (需权限)

// 在路由文件中添加
router.get('/getUserNotifications',getUserNotifications);
router.put('/markNotificationAsRead',markNotificationAsRead);

// 心理知识文章
router.post('/addPsychologyKnowledge', addPsychologyKnowledge);
router.post('/getPsychologyKnowledgeList', getPsychologyKnowledgeList);
router.post('/getPsychologyKnowledgeById', getPsychologyKnowledgeById);//ID
router.post('/updatePsychologyKnowledge', updatePsychologyKnowledge);
router.post('/deletePsychologyKnowledge', deletePsychologyKnowledge);
router.post('/likePsychologyKnowledge', likePsychologyKnowledge);
router.post('/getRandomPsychologyKnowledge', getRandomPsychologyKnowledge);
router.post('/searchPsychologyKnowledge', searchPsychologyKnowledge);

// 批量导入心理知识文章路由
router.post('/uploadXlsxPsychologyKnowledge', upload.single('file'), uploadXlsxPsychologyKnowledge);

// 创建心理问卷
router.post('/createQuestionnaire', createQuestionnaire);
router.post('/getQuestionnaireList', getQuestionnaireList);
router.post('/updateQuestionnaire', updateQuestionnaire);
router.post('/deleteQuestionnaire', deleteQuestionnaire);
router.post('/uploadXlsxPsychologyKnowledge', uploadXlsxPsychologyKnowledge);

// 添加题目
router.post('/addQuestion', addQuestion);
router.post('/getQuestionList', getQuestionList);
router.post('/updateQuestion', updateQuestion);
router.post('/deleteQuestion', deleteQuestion);

// 添加题目到问卷
router.post('/addQuestionToQuestionnaire', addQuestionToQuestionnaire);
router.post('/removeQuestionFromQuestionnaire', removeQuestionFromQuestionnaire);
router.post('/getQuestionnaireQuestions', getQuestionnaireQuestions);
router.post('/uploadXlsxQuestions', upload.single('file'), uploadXlsxQuestions);

//答题和批改
router.post('/submitQuestionnaire',submitQuestionnaire);
router.post('/gradeQuestionnaire',gradeQuestionnaire);
router.post('/generatePsychologyReport',generatePsychologyReport);


// 创建心理报告
router.post('/createPsychologyReport', createPsychologyReport);
router.post('/updatePsychologyReport', updatePsychologyReport);
router.post('/deletePsychologyReport', deletePsychologyReport);
router.post('/getUserPsychologyReports', getUserPsychologyReports);
router.post('/getPsychologyReportDetails', getPsychologyReportDetails);
router.post('/ImportQuestionScoreRanges', upload.single('file'), ImportQuestionScoreRanges);// 批量导入题目分数段和心理状态关联
router.post('/ImportQuestions', upload.single('file'), ImportQuestions);// 批量导入题目

//上传图片
router.post('/uploadImage', uploadImage);


// 多个文件上传
router.post('/uploadFiles', upload.array('file', 9), uploadFileLocal)
module.exports = router;
